import actionTypes from "./actionTypes"
import service from '../../service'
export function LoadPowerAction(payload){
  return{
    type:actionTypes.LOAD_POWER_LIST,
    payload:payload,
  }
}
export function LoadPowerActionAsync(payload){
  return dispatch=>{
    return service.loadPowerList(payload).then((res)=>{
      dispatch(LoadPowerAction(res.data))
    })
  }
}
export function addPowerAction(payload){
  return{
    type:actionTypes.ADD_POWER,
    payload:payload,
  }
}
export function addPowerActionAsync(payload){
  return dispatch=>{
    return service.addPower(payload).then((res)=>{
      dispatch(addPowerAction(res.data))
    })
  }
}
export function deletePowerActionAsync(payload){
  return dispatch=>{
    return service.deletePower(payload)
  }
}
export function updatePowerActionAsync(payload){
  return dispatch=>{
    return service.updatePower(payload)
  }
}
export function searchPowerActionAsync(payload){
  return dispatch=>{
    return service.searchPower(payload).then((res)=>{
      dispatch(LoadPowerAction(res.data))
    })
  }
}